const models = require('../../models');
const sequelize = models.db1;
const sql_pool = require('../sql_pool/achievingRate_sql');


module.exports = {
    shiyan: async (ctx) =>{
        console.log(ctx)
        ctx.body =  {data: "1111"}
    },

    AchievingRateQuanwang: async (ctx) => {
        const params = ctx.request.body
        const sql = sql_pool.AchievingRateQuanwang_sql(params); // sql语句
        const limit_sql = sql_pool.limit_sql(params); // sql语句
        const res = await sequelize.query(sql.sql + limit_sql, {
          type: sequelize.QueryTypes.SELECT
        })
        const in_total = await sequelize.query(sql.sql2, {
          type: sequelize.QueryTypes.SELECT
        })
        const data = {
          records: Object.values(res[1]),
          current: params.current + 1,
          size: params.size,
          total: res[0]['0']['count(1)'],
          in_total:in_total
        }
        ctx.body =  {
            data: data,
            code: 1,
            msg: "success"
        }

    }
}


